home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / adasmall / shel.ada < prev    next >
Text File  |  1996-01-30  |  1KB  |  62 lines

  1. with SMALL_SP; use SMALL_SP;
  2. procedure SHEL is
  3.  
  4.      B : STRING(0..25);
  5.      TEMP : CHARACTER;
  6.      I,J,STEP : INTEGER;
  7.      STEPSIZE : array(1..4) OF INTEGER;
  8.      STOP : BOOLEAN;
  9.      ROW : INTEGER;
  10.      STIME : FLOAT;
  11.  
  12. begin
  13.  B := "ZYXWVUTSRQPONMLKJIHGFEDCBA";
  14.  CURSORAT(7,1); PUT("Shell:");
  15.  STIME := CLOCK + 10.0;
  16.  ROW := 7;
  17.  for k in 0..25 loop
  18.   CURSORAT(row,14+k);
  19.   PUT(b(k));
  20.  end loop;
  21.  -- 'steps' contains decreasing increments for each
  22.  -- pass. The last pass has increment 1.
  23.  STEPSIZE(4) := 1;
  24.  for PASS in reverse 1..3 loop
  25.   STEPSIZE(PASS):= 2*STEPSIZE(PASS+1);
  26.  end loop;
  27.  
  28. -- delay STIME - CLOCK;
  29. for PASS in 1..4 loop
  30.  STEP := STEPSIZE(PASS);
  31.  I:= STEP;
  32.  while (I <= 25) loop
  33.   TEMP := B(I);
  34.   J:= I;
  35.   STOP:= FALSE;
  36.   while (J > STEP-1) and (STOP /= TRUE) loop
  37.    J := J - STEP;
  38.    if B(J) > TEMP then
  39.     B(J+STEP):= B(J);
  40.     CURSORAT(ROW,14+J);
  41.     PUT(TEMP);
  42.    else
  43.     B(J+STEP):= TEMP;
  44.     STOP:= TRUE;
  45.    end if;
  46.    CURSORAT(ROW, 14+(J+STEP));
  47.    PUT(B(J+STEP));
  48.   end loop;
  49.   if (not STOP) then
  50.    B(0):= TEMP;
  51.    CURSORAT(ROW,14);
  52.    PUT(B(0));
  53.   end if;
  54.   I := I + STEP;
  55.  end loop;
  56. end loop; -- for pass in 1..npass
  57. cursorat(19,1);
  58. put_line("Press any key to continue..."); get(i);
  59. end SHEL;
  60.  
  61.  
  62.